package com.jxm.controller;

import java.util.HashMap;
import java.util.Map;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;

public class BaseController extends Controller{
	
	/**
	 * 统一做分页处理
	 * @param page
	 */
	public void renderPageForLayUI(Page<?> page){
		Map<String, Object> result = new HashMap<>();
		result.put("code", 0);
		result.put("msg", "");
		result.put("count", page.getTotalRow());
		result.put("data", page.getList());
		renderJson(result);
	}
	/**
	 * 第几页
	 * @return
	 */
	protected int getPage(){
		return this.getParaToInt("page");
	}
	
	/**
	 * 页面数量
	 * @return
	 */
	protected int getLimit(){
		return this.getParaToInt("limit");
	}

}
